#ifndef PYCALLBYC_H
#define PYCALLBYC_H
#include "Python.h"
#include <QDebug>
#include <iostream>

class PyCallByC
{
public:
    PyCallByC();
    void setScriptPath(const char* path);

    bool setPModule(const char* moduleName);

    bool setPFunc(const char* funcName);

    PyObject* CallFunc(PyObject* args = nullptr);

    ~PyCallByC();
private:
    PyObject* _pModule = nullptr;
    PyObject* _pFunc = nullptr;
};

class PyObjectRef {
public:
    PyObjectRef(PyObject* obj) : obj(obj) {}
    ~PyObjectRef() { Py_XDECREF(obj); }
    operator PyObject*() { return obj; }
    PyObject* get() { return obj; }
private:
    PyObject* obj;
};

#endif // PYCALLBYC_H
